package chart;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

//import utils.showChartDB;


public class chartDAO{
    String getOptions(int selectedId) {
        int counter = 0;                            
        StringBuffer opts = new StringBuffer("{");  
        String sql = "select * from Poll_Question order by PollID, QuestionID asc";
        Connection conn = null;                 
        PreparedStatement pstmt = null;         
        ResultSet rs = null;                    
        try {
          //  conn = showChartDB.getConnection();     
            pstmt = conn.prepareStatement(sql); 
            pstmt.setInt(1, selectedId);     
            rs = pstmt.executeQuery();    
            System.out.println(rs.next());      
            while (rs.next()) {                
              
                if (counter > 0) {
                    opts.append(",");
                }
                opts.append("'");
                opts.append(rs.getInt(1));
                opts.append("':'");
                opts.append(rs.getInt(2));
                opts.append("'");
                counter++;                   
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
          //  showChartDB.close(rs);        
          //  showChartDB.close(pstmt);      
          //  showChartDB.close(conn);      
        }
        opts.append("}");
        return opts.toString();
    }                                       

              
}                          
